package BlackJack.Control
{
	import BlackJack.Model.Events.LobbyEvent;
	import BlackJack.View.Lobby;
	import flash.display.StageDisplayState;
	import flash.display.StageQuality;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import org.robotlegs.mvcs.Command;

	public class LobbyCommand extends Command
	{
		[Inject]
		public var event:LobbyEvent;

		override public function execute():void
		{
			main.debug.MESSAGE(this + '\t' + event.type);
			var page:int = event.page;
			switch (event.type)
			{
				case LobbyEvent.Auto:
					break;
				case LobbyEvent.Charge:
					break;
				case LobbyEvent.Exit:
					break;
				case LobbyEvent.FullScreen:
				{
					contextView.stage.displayState = StageDisplayState.FULL_SCREEN;
					break;
				}
				case LobbyEvent.Guide:
				{
					var request:URLRequest = new URLRequest('http://golden.goldengame.com.tw/intro/intro_game.php?x=2&y=1');
					navigateToURL(request, '_blank');
					break;
				}
				case LobbyEvent.HighPerformance:
				{
					contextView.stage.quality = StageQuality.LOW;
					break;
				}
				case LobbyEvent.HighQuality:
				{
					contextView.stage.quality = StageQuality.BEST;
					break;
				}
				case LobbyEvent.LastPage:
				{
					main.socket.C2S_TablegetList(page, lobby.md5[page]);
					break;
				}
				case LobbyEvent.NextPage:
				{
					main.socket.C2S_TablegetList(page, lobby.md5[page]);
					break;
				}
				case LobbyEvent.NormalScreen:
				{
					contextView.stage.displayState = StageDisplayState.NORMAL;
					break;
				}
				case LobbyEvent.SoundOff:
					break;
				case LobbyEvent.SoundOn:
					break;
			}
		}

		public function get main():BlackJackMain
		{
			return contextView as BlackJackMain;
		}

		public function get lobby():Lobby
		{
			return main.lobby;
		}
	}
}
